package com.zygh.policeasset.config;

import com.zygh.policeasset.utils.SpringContextUtil;
import java.lang.reflect.Method;
import java.util.Objects;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.ReflectionUtils;

/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/config/SchedulingRunnable.class */
public class SchedulingRunnable implements Runnable {
    private static final Logger logger = LoggerFactory.getLogger(SchedulingRunnable.class);
    private String beanName;
    private String methodName;
    private String params;

    public SchedulingRunnable(String beanName, String methodName) {
        this(beanName, methodName, null);
    }

    public SchedulingRunnable(String beanName, String methodName, String params) {
        this.beanName = beanName;
        this.methodName = methodName;
        this.params = params;
    }

    @Override // java.lang.Runnable
    public void run() {
        Method method;
        logger.info("定时任务开始执行 - bean：{}，方法：{}，参数：{}", this.beanName, this.methodName, this.params);
        long startTime = System.currentTimeMillis();
        try {
            Object target = SpringContextUtil.getBean(this.beanName);
            if (StringUtils.isNotEmpty(this.params)) {
                method = target.getClass().getDeclaredMethod(this.methodName, String.class);
            } else {
                method = target.getClass().getDeclaredMethod(this.methodName, new Class[0]);
            }
            ReflectionUtils.makeAccessible(method);
            if (StringUtils.isNotEmpty(this.params)) {
                method.invoke(target, this.params);
            } else {
                method.invoke(target, new Object[0]);
            }
        } catch (Exception ex) {
            logger.error(String.format("定时任务执行异常 - bean：%s，方法：%s，参数：%s ", this.beanName, this.methodName, this.params), (Throwable) ex);
        }
        logger.info("定时任务执行结束 - bean：{}，方法：{}，参数：{}，耗时：{} 毫秒", this.beanName, this.methodName, this.params, Long.valueOf(System.currentTimeMillis() - startTime));
    }

    @Override // java.lang.Object
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        SchedulingRunnable that = (SchedulingRunnable) o;
        return this.params == null ? this.beanName.equals(that.beanName) && this.methodName.equals(that.methodName) && that.params == null : this.beanName.equals(that.beanName) && this.methodName.equals(that.methodName) && this.params.equals(that.params);
    }

    @Override // java.lang.Object
    public int hashCode() {
        return this.params == null ? Objects.hash(this.beanName, this.methodName) : Objects.hash(this.beanName, this.methodName, this.params);
    }
}